﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UI
{
    public class FormUtil : Form
    {
        private FormUtil()
        {

        }
        public const string EMPLOYEE_FORM = "员工管理";
        public const string DEPARTMENT_FORM = "部门管理";
        public const string MANAGER_SET_FORM = "管理员设置";

        // 获取单例
        public class CreateSingleton<T> where T : Form, new()
        {
            private static T t = null;
            public static T getInstrance()
            {
                if (t == null || t.IsDisposed)
                {
                    t = new T();
                }
                else
                {
                    t.Activate(); //如果已经打开过就让其获得焦点  
                    t.WindowState = FormWindowState.Normal;//使Form恢复正常窗体大小
                }
                return t;
            }
        }
        public static EmployeeForm getEmployeeForm()
        {
            return CreateSingleton<EmployeeForm>.getInstrance();
        }
        public static DeptForm getDepartmentForm()
        {
            return CreateSingleton<DeptForm>.getInstrance();
        }
        public static ManagerSetForm getManagerForm()
        {
            return CreateSingleton<ManagerSetForm>.getInstrance();
        }
    }
}
